#include <iostream>
#include <vector>
#include <queue>

using namespace std;
const int N = 110;
int n;
vector<int>edges[N];
int in[N];
queue<int> q;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int x;
		while (cin >> x, x)
		{
			edges[i].push_back(x);
			in[x]++;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		if (in[i] == 0) q.push(i);
	}
	while (q.size())
	{
		int t = q.front(); q.pop();
		cout << t << " ";
		for (auto k : edges[t])
		{
			in[k]--;
			if (in[k] == 0) q.push(k);
		}
	}
	cout << endl;
	return 0;
}